<cfparam name="userID" type="integer">
<cfparam name="organizationID" type="integer">
<cfparam name="rv" type="string" default="settings">

<cfset user = application.userGateway.get(userID, organizationID)>

<cfoutput>

	<cfif user.getUser_ID() gt 0>
	
		<cfif authUser.getRole() neq "Site Contact" or authUser.getUser_ID() eq userID>
			<cfset canEdit = true>
		<cfelse>
			<cfset canEdit = false>
		</cfif>
		
		<cfif authUser.getRole() neq "Site Contact" and NOT user.getApproved()>
			<cfset canApprove = true>
		<cfelse>
			<cfset canApprove = false>
		</cfif>
		
		<div class="buttonBar">
			<a href="#script_name#?view=#rv#&userID=#userID#&organizationID=#organizationID#" class="formLink2">Back</a>
			<cfif canEdit>
				<a href="#script_name#?view=editUser&rv=#view#&userID=#userID#&organizationID=#organizationID#" class="formLink">Edit</a>
			</cfif>
			<cfif canApprove>
				<a href="#script_name#?m=userDetailApprove&view=#rv#&userID=#userID#&organizationID=#organizationID#" class="formLink">Approve</a>
			</cfif>
		</div>
	
		<cfif IsUserInRole("Super User") or IsUserInRole("Regional Admin")>
			<cfinclude template="#request.pathToUI#/details/organization.cfm">
		</cfif>
		
		<table class="detail">
			<tr>
				<cfif authUser.getUser_ID() eq user.getUser_ID()>
					<th>Your Account</th>
				<cfelse>
					<th>User</th>
				</cfif>
			</tr>
			<tr>
				<td>
					<cfif userID gt 0>
						User ID: #user.getUser_ID()#<br>
					</cfif>
					Status: <cfif user.getApproved()>Approved<cfelse><cfif IsUserInRole("Super User") or IsUserInRole("Regional Admin")><font color="red">Not approved</font><cfelse>Pending approval</cfif></cfif><br>
					<cfif userID eq authUser.getUser_ID()>
						<a href="#script_name#?view=editUser&rv=#view#&userID=#userID#&organizationID=#organizationID#">#user.getFirst_Name()# #user.getLast_Name()#</a><br>
					<cfelse>
						#user.getFirst_Name()# #user.getLast_Name()#<br>
					</cfif>
					Role: #user.getRole()#<br>
					<cfif Len(Trim(user.getTitle())) gt 0>#user.getTitle()#<br></cfif>
					#user.getPhone()#<cfif Len(Trim(user.getExtension())) gt 0>&nbsp;x&nbsp;#user.getExtension()#</cfif><br>
					<a href="mailto:#user.getEmail()#">#user.getEmail()#</a><br>				
				</td>
			</tr>
		</table>
		
	<cfelse>
		<div class="alert alert-info notFound">User not found</div>
	</cfif>

</cfoutput>